home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
726-750
/
729
/
bbbbs
/
bbbbs54.lzh
/
rexx
/
bbsREPORT.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-07-27
|
9KB
|
340 lines
/* $VER: 5.3 bbsREPORT.rexx 27 Jul 1992 (27.7.92)
- reports user inactivity -
- any user who hasn't called for 365 days -
- less than 3 calls with last older than 270 days -
- only 1 call made more than 180 days ago -
- CHANGE THESE LIMITS IF YOU DON'T LIKE THEM! -
- also will report filelist problems -
copyright 1991-92 Richard Lee Stockton FREELY DISTRIBUTABLE
*/
HOW_MANY=100 /* how many old files to put on report */
MIN_DAYS=30 /* don't report files younger than this (in days) */
least.=999999999999
CALL PRAGMA('P',-2)
SIGNAL ON ERROR
SIGNAL ON SYNTAX
SIGNAL ON FAILURE
NUMERIC DIGITS 14
ARG name what2do
temp=STRIP(WORD(what2do,WORDS(what2do)))
IF DATATYPE(temp,'N') THEN SMALLEST=temp
ELSE SMALLEST=0
figarg='s:CONFIG.BBS'
IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
x=OPEN(f,figarg,'R')
IF x=0 THEN
DO
SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
EXIT(20)
END
lynes.=''
DO i=1 TO 8
lynes.i=READLN(f)
END
CALL CLOSE(f)
compos=POS('/*',lynes.1)
IF compos>0 THEN lynes.1=LEFT(lynes.1,compos-1)
bbsname = STRIP(lynes.1)
sysop = UPPER(WORD(lynes.2,1))
bbspath = WORD(lynes.6,1)
IF ~EXISTS(bbspath) THEN
DO
SAY bbspath 'does not exist!'
EXIT(20)
END
testchar=RIGHT(bbspath,1)
IF testchar~='/' & testchar~=':' THEN bbspath=bbspath'/'
libpath = WORD(lynes.8,1)
IF ~EXISTS(libpath) THEN
DO
MSG libpath 'does not exist!'
EXIT(20)
END
testchar=RIGHT(libpath,1)
IF testchar~='/' & testchar~=':' THEN libpath=libpath'/'
IF FIND(what2do,'USERS')=0 THEN SIGNAL FILEREPORT
inarg=bbspath'EMail/'name'/INACTIVE_USERS'
CALL CLOSE(STDOUT)
CALL OPEN(STDOUT,inarg,'W')
IF x=0 THEN
DO
SAY inarg 'would not open for writing!'
EXIT(20)
END
userlist=SHOWDIR(bbspath'Users','F')
x=FIND(userlist,sysop)
IF x>0 THEN userlist=DELWORD(userlist,x,1)
SAY LEFT('USER_NAME',28)'days last_session calls location'
DO i=1 TO WORDS(userlist)
thisuser=WORD(userlist,i)
x=OPEN(f,bbspath'Users/'thisuser,'R')
IF x=0 THEN
DO
SAY thisuser 'userfile would not open!'
ITERATE i
END
lynes.=''
DO j=1 TO 23
line=READLN(f)
IF EOF(f) THEN LEAVE j
lynes.j=line
END
CALL CLOSE(f)
idate=0
add2list=0
IF DATATYPE(WORD(lynes.13,1),'N') THEN
DO
idate=DATE('I',STRIP(WORD(lynes.13,1)),'S')
ndate=DATE('I')
IF FIND(lynes.21,'VIP_USER')>0 THEN NOP
ELSE IF (idate+365)<ndate THEN add2list=365
ELSE IF WORD(lynes.19,6)<4 & (idate+270)<ndate THEN add2list=270
ELSE IF WORD(lynes.19,6)<2 & (idate+180)<ndate THEN add2list=180
IF add2list>0 THEN
DO
line=LEFT(thisuser,28) RIGHT(add2list,3)' 'DATE(,WORD(lynes.13,1),'S')
line=line' 'WORD(lynes.19,6)' 'lynes.3
SAY line
END
END
ELSE SAY 'Bad Date!' thisuser lynes.13
END
IF GETCLIP('BBS_level')~='' & WORD(GETCLIP('BBS_lastcaller'),1)=name THEN
CALL SETCLIP('BBS_MESSAGE','INACTIVE_USERS report is waiting in Email.')
FILEREPORT:
IF FIND(what2do,'FILES')=0 THEN EXIT(0)
inarg=bbspath'EMail/'name'/FILELISTS_REPORT'
CALL CLOSE(STDOUT)
CALL OPEN(STDOUT,inarg,'W')
IF x=0 THEN
DO
SAY inarg 'would not open for writing!'
EXIT(20)
END
SAY ' - FileReport -' DATE('W')' 'DATE()' 'TIME('C')
SAY LEFT('-',75,'-')
dirs.='0000000'
IF readopen(bbspath'Lists/Libraries') THEN
DO
DO i=1
line=READLN(f)
IF line='END' | EOF(f) THEN LEAVE i
num=WORD(line,1)
IF DATATYPE(num,'N') THEN dirs.num=STRIP(WORD(line,2))
END
CALL CLOSE(f)
END
problem=0
IF readopen(bbspath'Lists/Files') THEN
DO
DO i=1
line=READLN(f)
IF EOF(f) THEN BREAK
realfile=libpath||COMPRESS(WORD(line,2)'/'WORD(line,3),' ')
IF EXISTS(realfile) THEN ITERATE i
link=STATEF(bbspath'FileNotes/'COMPRESS(WORD(line,2)'/'WORD(line,3)))
link=WORD(link,8)
IF link~='' THEN realfile=link
IF EXISTS(realfile) THEN ITERATE i
SAY realfile 'does not exist!'
problem=1
END
CALL CLOSE(f)
END
IF ~problem THEN SAY 'All files in the master list exist as links or in the libraries.'
ELSE SAY 'The above files in the master list are not available for downloading!'
SAY i-1 'files listed in ''Lists/Files''.'
k=0
kk=0
DO i=1 TO 99
IF dirs.i='' | dirs.i='0000000' THEN ITERATE i
realfiles=SHOWDIR(libpath||dirs.i)
k=k+WORDS(realfiles)
DO j=1 TO WORDS(realfiles)
DO
file=dirs.i'/'STRIP(WORD(realfiles,j))
IF ~EXISTS(bbspath'FileNotes/'file) THEN
SAY 'No file description for' file WORD(STATEF(libpath||file),2) 'bytes.'
END
END
notes=SHOWDIR(bbspath'FileNotes/'dirs.i)
DO j=1 TO WORDS(notes)
thisnote=bbspath'FileNotes/'dirs.i'/'STRIP(WORD(notes,j))
x=OPEN(f,thisnote,'R')
IF x=0 THEN ITERATE j
line1=READLN(f)
line2=READLN(f)
line3=READLN(f)
CALL CLOSE(f)
kk=kk+1
IF ~EXISTS(libpath||dirs.i'/'STRIP(WORD(notes,j))) THEN
DO
link=WORD(STATEF(thisnote),8)
IF link='' THEN ITERATE j
ELSE
DO
IF EXISTS(link) THEN k=k+1
ELSE ITERATE j
END
END
filenum=WORD(line1,2)
nname=WORD(line2,2)
size=WORD(line2,4)
dlds=WORD(line2,7)
dirs.i.1=dirs.i.1+1 /* files this dir */
dirs.i.2=dirs.i.2+size /* bytes this dir */
dirs.i.3=dirs.i.3+dlds /* dloads this dir */
IF size<SMALLEST THEN ITERATE j
uldate=norm2seq(SUBWORD(line3,4,3))
IF uldate<19000000 | uldate>99991231 THEN
DO
SAY 'Bad Date! 'SUBWORD(line3,4,3) thisnote
ITERATE j
END
IF DATE('I',uldate,'S')>(DATE('I')-MIN_DAYS) THEN ITERATE j
DO jj=HOW_MANY TO 1 BY -1
IF dlds>least.jj THEN ITERATE j
IF dlds=least.jj & uldate>least.jj.0 THEN ITERATE j
jjj=jj+1
least.jjj=least.jj
least.jjj.0=least.jj.0
least.jjj.1=least.jj.1
least.jj=dlds
least.jj.0=uldate
least.jj.1=RIGHT(size,8) RIGHT(filenum,6) LEFT(dirs.i,16) nname
END
END
END
SAY kk 'filenotes.'
SAY k 'actual files in libraries.'
IF readopen(bbspath'Lists/Files.ALPHA') THEN
DO
DO i=1
line=READLN(f)
IF EOF(f) THEN BREAK
END
CALL CLOSE(f)
END
SAY i-1 'files listed in ''Lists/Files.ALPHA''.'
SAY
SAY ' - The 'HOW_MANY' least downloaded, oldest files greater -'
SAY ' - than' comma(SMALLEST) 'bytes in the current libraries -'
SAY RIGHT('dls',5) LEFT('Date',11) RIGHT('Bytes',8) 'File #' LEFT('Library',16) 'Filename'
SAY LEFT('-',62,'-')
DO i=1 TO HOW_MANY
SAY RIGHT(least.i,5) DATE(,least.i.0,'S') least.i.1
END
SAY
SAY ' - LIBRARY STATISTICS -'
SAY RIGHT('Lib#',4) LEFT('Library Name',16) RIGHT('Files',5) RIGHT('Bytes',14) RIGHT('Downloads',9) RIGHT('AverageSize',11) RIGHT('DL/file',7)
SAY LEFT('-',72,'-')
tots.=0
DO i=1 TO 99
IF dirs.i='' | dirs.i=0 THEN ITERATE i
DO j=1 TO 3
tots.j=tots.j+dirs.i.j
END
temp=dirs.i.1
IF temp<1 THEN temp=1
SAY RIGHT(i,4) LEFT(dirs.i,16) RIGHT(comma(dirs.i.1),5) RIGHT(comma(dirs.i.2),14) RIGHT(comma(dirs.i.3),9) RIGHT(comma((.5+dirs.i.2/temp)%1),11) RIGHT(TRUNC(dirs.i.3/temp,2),7)
END
SAY
SAY LEFT('',21) RIGHT('Files',5) RIGHT('Bytes',14) RIGHT('Downloads',9) RIGHT('AverageSize',11) RIGHT('DL/file',7)
SAY LEFT('-',72,'-')
temp=tots.1
IF temp<1 THEN temp=1
SAY RIGHT('TOTALS:',21) RIGHT(comma(tots.1),5) RIGHT(comma(tots.2),14) RIGHT(comma(tots.3),9) RIGHT(comma((.5+tots.2/temp)%1),11) RIGHT(TRUNC(tots.3/temp,2),7)
SAY
SAY ' - end of filelist report -'
IF GETCLIP('BBS_level')~='' & WORD(GETCLIP('BBS_lastcaller'),1)=name THEN
CALL SETCLIP('BBS_MESSAGE','FILELISTS_REPORT is waiting in Email.')
EXIT(0);
readopen:
PARSE ARG fname
ok=OPEN(f,fname,'R')
IF ok~=0 THEN RETURN(1)
line=fname 'failed to open for reading!'
SAY line
RETURN(0)
norm2seq: /* takes '3 Jan 1990' and turns it into '19900103' */
ARG da' 'mo' 'yr .
da=da/1
mo=STRIP(mo)
yr=yr/1
IF da<10 THEN da='0'da
SELECT
WHEN mo='JAN' THEN mo='01'
WHEN mo='FEB' THEN mo='02'
WHEN mo='MAR' THEN mo='03'
WHEN mo='APR' THEN mo='04'
WHEN mo='MAY' THEN mo='05'
WHEN mo='JUN' THEN mo='06'
WHEN mo='JUL' THEN mo='07'
WHEN mo='AUG' THEN mo='08'
WHEN mo='SEP' THEN mo='09'
WHEN mo='OCT' THEN mo='10'
WHEN mo='NOV' THEN mo='11'
WHEN mo='DEC' THEN mo='12'
OTHERWISE RETURN(-1);
END
RETURN(yr||mo||da);
comma:
ARG num .
num=num%1
dgt=LENGTH(num)
numtext=''
IF dgt>3 THEN numtext=','RIGHT(num,3)
IF dgt>6 THEN numtext=','LEFT(RIGHT(num,6),3)||numtext
IF dgt>9 THEN
DO
numtext=','LEFT(RIGHT(num,9),3)||numtext
numtext=LEFT(num,dgt-9)||numtext
END
ELSE IF dgt>6 THEN numtext=LEFT(num,dgt-6)||numtext
ELSE IF dgt>3 THEN numtext=LEFT(num,dgt-3)||numtext
ELSE numtext=num
RETURN(numtext)
SYNTAX:
FAILURE:
ERROR:
SAY 'Line:' SIGL ERRORTEXT(RC)
SAY
EXIT;
/* end of bbsREPORT.rexx */